<template>
  <div class="study-plan">
    <!-- 页面头部 -->
    <div class="page-header">
      <button class="back-btn" @click="goBack">
        ← 返回
      </button>
      <h1>📅 学习计划</h1>
      <div class="header-actions">
        <button class="action-btn create-btn" @click="showCreatePlan = true">
          ➕ 创建计划
        </button>
        <button class="action-btn template-btn" @click="showTemplates = true">
          📋 使用模板
        </button>
      </div>
    </div>

    <!-- 主要内容 -->
    <div class="content-container">
      <!-- 当前计划概览 -->
      <div class="plan-overview">
        <div class="overview-header">
          <h2>📊 当前计划概览</h2>
          <div class="plan-selector">
            <label>选择孩子：</label>
            <select v-model="selectedChildId" class="child-select">
              <option v-for="child in children" :key="child.id" :value="child.id">
                {{ child.name }}
              </option>
            </select>
          </div>
        </div>
        
        <div class="overview-stats">
          <div class="overview-stat">
            <div class="stat-icon">📅</div>
            <div class="stat-info">
              <div class="stat-value">{{ currentPlan.duration }}天</div>
              <div class="stat-label">计划周期</div>
            </div>
          </div>
          <div class="overview-stat">
            <div class="stat-icon">✅</div>
            <div class="stat-info">
              <div class="stat-value">{{ currentPlan.completedTasks }}/{{ currentPlan.totalTasks }}</div>
              <div class="stat-label">已完成任务</div>
            </div>
          </div>
          <div class="overview-stat">
            <div class="stat-icon">📈</div>
            <div class="stat-info">
              <div class="stat-value">{{ currentPlan.completionRate }}%</div>
              <div class="stat-label">完成率</div>
            </div>
          </div>
          <div class="overview-stat">
            <div class="stat-icon">🔥</div>
            <div class="stat-info">
              <div class="stat-value">{{ currentPlan.streakDays }}天</div>
              <div class="stat-label">连续学习</div>
            </div>
          </div>
        </div>

        <div class="plan-progress">
          <div class="progress-header">
            <span>整体进度</span>
            <span class="progress-percent">{{ currentPlan.completionRate }}%</span>
          </div>
          <div class="progress-bar-large">
            <div class="progress-fill-large" :style="{ width: `${currentPlan.completionRate}%` }"></div>
          </div>
        </div>
      </div>

      <!-- 日历视图和任务列表 -->
      <div class="plan-content-grid">
        <!-- 日历视图 -->
        <div class="calendar-section">
          <div class="calendar-header">
            <button class="calendar-nav-btn" @click="previousMonth">←</button>
            <h3>{{ currentMonthYear }}</h3>
            <button class="calendar-nav-btn" @click="nextMonth">→</button>
          </div>
          <div class="calendar-grid">
            <div class="calendar-weekday" v-for="day in weekdays" :key="day">{{ day }}</div>
            <div 
              v-for="(date, index) in calendarDays" 
              :key="index"
              class="calendar-day"
              :class="{
                'other-month': date.otherMonth,
                'today': date.isToday,
                'has-task': date.hasTask,
                'completed': date.completed
              }"
              @click="selectDate(date)"
            >
              <span class="day-number">{{ date.day }}</span>
              <div v-if="date.hasTask" class="day-indicator">
                <span v-if="date.completed" class="completed-dot">✓</span>
                <span v-else class="task-dot">•</span>
              </div>
            </div>
          </div>
        </div>

        <!-- 任务列表 -->
        <div class="tasks-section">
          <div class="tasks-header">
            <h3>📝 今日任务</h3>
            <div class="tasks-filter">
              <button 
                v-for="filter in taskFilters" 
                :key="filter.value"
                class="filter-btn"
                :class="{ active: selectedFilter === filter.value }"
                @click="selectedFilter = filter.value"
              >
                {{ filter.label }}
              </button>
            </div>
          </div>
          
          <div class="tasks-list">
            <div 
              v-for="task in filteredTasks" 
              :key="task.id"
              class="task-item"
              :class="{ completed: task.completed }"
            >
              <div class="task-checkbox" @click="toggleTask(task)">
                <span v-if="task.completed" class="check-icon">✓</span>
              </div>
              <div class="task-content">
                <div class="task-title">{{ task.title }}</div>
                <div class="task-meta">
                  <span class="task-module">{{ task.module }}</span>
                  <span class="task-time">{{ task.time }}</span>
                </div>
              </div>
              <div class="task-actions">
                <button class="task-action-btn" @click="editTask(task)">✏️</button>
                <button class="task-action-btn" @click="deleteTask(task)">🗑️</button>
              </div>
            </div>
            
            <div v-if="filteredTasks.length === 0" class="empty-tasks">
              <div class="empty-icon">📭</div>
              <p>暂无任务</p>
            </div>
          </div>

          <button class="add-task-btn" @click="showAddTask = true">
            ➕ 添加任务
          </button>
        </div>
      </div>

      <!-- 计划设置 -->
      <div class="plan-settings">
        <h2>⚙️ 计划设置</h2>
        <div class="settings-grid">
          <div class="setting-item">
            <label>每日学习时长</label>
            <div class="setting-value">{{ planSettings.dailyDuration }}分钟</div>
            <input 
              type="range" 
              v-model="planSettings.dailyDuration" 
              min="15" 
              max="120" 
              step="15"
              class="setting-slider"
            >
          </div>
          <div class="setting-item">
            <label>每周学习天数</label>
            <div class="setting-value">{{ planSettings.weeklyDays }}天</div>
            <input 
              type="range" 
              v-model="planSettings.weeklyDays" 
              min="3" 
              max="7" 
              step="1"
              class="setting-slider"
            >
          </div>
          <div class="setting-item">
            <label>学习提醒</label>
            <div class="setting-toggle">
              <label class="toggle-switch">
                <input type="checkbox" v-model="planSettings.reminderEnabled">
                <span class="toggle-slider"></span>
              </label>
              <span class="toggle-label">{{ planSettings.reminderEnabled ? '已开启' : '已关闭' }}</span>
            </div>
          </div>
          <div class="setting-item">
            <label>提醒时间</label>
            <input 
              type="time" 
              v-model="planSettings.reminderTime"
              class="time-input"
              :disabled="!planSettings.reminderEnabled"
            >
          </div>
        </div>
        <button class="save-settings-btn" @click="saveSettings">💾 保存设置</button>
      </div>
    </div>

    <!-- 创建计划弹窗 -->
    <div v-if="showCreatePlan" class="modal-overlay" @click="showCreatePlan = false">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h3>创建学习计划</h3>
          <button class="modal-close" @click="showCreatePlan = false">×</button>
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label>计划名称</label>
            <input type="text" v-model="newPlan.name" placeholder="例如：11月学习计划" class="form-input">
          </div>
          <div class="form-group">
            <label>计划周期</label>
            <div class="form-row">
              <input type="date" v-model="newPlan.startDate" class="form-input">
              <span>至</span>
              <input type="date" v-model="newPlan.endDate" class="form-input">
            </div>
          </div>
          <div class="form-group">
            <label>学习目标</label>
            <textarea v-model="newPlan.goals" placeholder="描述学习目标..." class="form-textarea" rows="3"></textarea>
          </div>
        </div>
        <div class="modal-footer">
          <button class="btn-cancel" @click="showCreatePlan = false">取消</button>
          <button class="btn-confirm" @click="createPlan">创建</button>
        </div>
      </div>
    </div>

    <!-- 添加任务弹窗 -->
    <div v-if="showAddTask" class="modal-overlay" @click="showAddTask = false">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h3>添加任务</h3>
          <button class="modal-close" @click="showAddTask = false">×</button>
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label>任务名称</label>
            <input type="text" v-model="newTask.title" placeholder="例如：完成单词游戏第3关" class="form-input">
          </div>
          <div class="form-group">
            <label>所属模块</label>
            <select v-model="newTask.module" class="form-input">
              <option value="listening">磨耳朵听力</option>
              <option value="reading">绘本阅读</option>
              <option value="game">单词游戏</option>
            </select>
          </div>
          <div class="form-group">
            <label>计划日期</label>
            <input type="date" v-model="newTask.date" class="form-input">
          </div>
          <div class="form-group">
            <label>预计时长（分钟）</label>
            <input type="number" v-model="newTask.duration" min="5" max="60" step="5" class="form-input">
          </div>
        </div>
        <div class="modal-footer">
          <button class="btn-cancel" @click="showAddTask = false">取消</button>
          <button class="btn-confirm" @click="addTask">添加</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'StudyPlan',
  data() {
    return {
      selectedChildId: 1,
      children: [
        { id: 1, name: '小明' },
        { id: 2, name: '小红' }
      ],
      currentPlan: {
        name: '11月学习计划',
        duration: 30,
        completedTasks: 18,
        totalTasks: 30,
        completionRate: 60,
        streakDays: 7
      },
      currentDate: new Date(),
      weekdays: ['日', '一', '二', '三', '四', '五', '六'],
      selectedFilter: 'all',
      taskFilters: [
        { label: '全部', value: 'all' },
        { label: '待完成', value: 'pending' },
        { label: '已完成', value: 'completed' }
      ],
      tasks: [
        {
          id: 1,
          title: '完成单词游戏第3关',
          module: '单词游戏',
          time: '15分钟',
          date: new Date().toISOString().split('T')[0],
          completed: false
        },
        {
          id: 2,
          title: '阅读绘本《小王子》第5-8页',
          module: '绘本阅读',
          time: '20分钟',
          date: new Date().toISOString().split('T')[0],
          completed: true
        },
        {
          id: 3,
          title: '听力练习：英文儿歌3首',
          module: '磨耳朵听力',
          time: '25分钟',
          date: new Date().toISOString().split('T')[0],
          completed: false
        }
      ],
      planSettings: {
        dailyDuration: 30,
        weeklyDays: 5,
        reminderEnabled: true,
        reminderTime: '19:00'
      },
      showCreatePlan: false,
      showAddTask: false,
      showTemplates: false,
      newPlan: {
        name: '',
        startDate: '',
        endDate: '',
        goals: ''
      },
      newTask: {
        title: '',
        module: 'game',
        date: new Date().toISOString().split('T')[0],
        duration: 15
      }
    };
  },
  computed: {
    currentMonthYear() {
      return `${this.currentDate.getFullYear()}年${this.currentDate.getMonth() + 1}月`;
    },
    calendarDays() {
      const year = this.currentDate.getFullYear();
      const month = this.currentDate.getMonth();
      const firstDay = new Date(year, month, 1);
      const lastDay = new Date(year, month + 1, 0);
      const days = [];
      
      // 上个月的日期
      const prevMonthLastDay = new Date(year, month, 0).getDate();
      const firstDayWeekday = firstDay.getDay();
      for (let i = firstDayWeekday - 1; i >= 0; i--) {
        days.push({
          day: prevMonthLastDay - i,
          otherMonth: true,
          isToday: false,
          hasTask: false,
          completed: false
        });
      }
      
      // 当前月的日期
      const today = new Date();
      for (let day = 1; day <= lastDay.getDate(); day++) {
        const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
        const task = this.tasks.find(t => t.date === dateStr);
        days.push({
          day,
          otherMonth: false,
          isToday: today.getFullYear() === year && today.getMonth() === month && today.getDate() === day,
          hasTask: !!task,
          completed: task?.completed || false
        });
      }
      
      // 下个月的日期（补齐到42天）
      const remainingDays = 42 - days.length;
      for (let day = 1; day <= remainingDays; day++) {
        days.push({
          day,
          otherMonth: true,
          isToday: false,
          hasTask: false,
          completed: false
        });
      }
      
      return days;
    },
    filteredTasks() {
      const today = new Date().toISOString().split('T')[0];
      let filtered = this.tasks.filter(t => t.date === today);
      
      if (this.selectedFilter === 'completed') {
        filtered = filtered.filter(t => t.completed);
      } else if (this.selectedFilter === 'pending') {
        filtered = filtered.filter(t => !t.completed);
      }
      
      return filtered;
    }
  },
  methods: {
    previousMonth() {
      this.currentDate = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth() - 1, 1);
    },
    nextMonth() {
      this.currentDate = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth() + 1, 1);
    },
    selectDate(date) {
      if (date.otherMonth) return;
      // 后续实现选择日期查看任务
      console.log('选择日期:', date);
    },
    toggleTask(task) {
      task.completed = !task.completed;
      this.updatePlanStats();
    },
    editTask(task) {
      // 后续实现编辑任务
      alert('编辑任务功能开发中...');
    },
    deleteTask(task) {
      if (confirm('确定要删除这个任务吗？')) {
        const index = this.tasks.findIndex(t => t.id === task.id);
        if (index > -1) {
          this.tasks.splice(index, 1);
          this.updatePlanStats();
        }
      }
    },
    addTask() {
      if (!this.newTask.title) {
        alert('请输入任务名称');
        return;
      }
      this.tasks.push({
        id: Date.now(),
        ...this.newTask,
        completed: false,
        time: `${this.newTask.duration}分钟`
      });
      this.newTask = {
        title: '',
        module: 'game',
        date: new Date().toISOString().split('T')[0],
        duration: 15
      };
      this.showAddTask = false;
      this.updatePlanStats();
    },
    createPlan() {
      if (!this.newPlan.name || !this.newPlan.startDate || !this.newPlan.endDate) {
        alert('请填写完整信息');
        return;
      }
      // 后续实现创建计划
      alert('创建计划功能开发中...');
      this.showCreatePlan = false;
    },
    saveSettings() {
      // 后续实现保存设置
      alert('设置已保存！');
    },
    updatePlanStats() {
      const completed = this.tasks.filter(t => t.completed).length;
      const total = this.tasks.length;
      this.currentPlan.completedTasks = completed;
      this.currentPlan.totalTasks = total;
      this.currentPlan.completionRate = total > 0 ? Math.round((completed / total) * 100) : 0;
    },
    goBack() {
      this.$router.push('/');
    }
  },
  mounted() {
    this.updatePlanStats();
  }
};
</script>

<style scoped>
.study-plan {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  flex-wrap: wrap;
}

.back-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateX(-5px);
}

.page-header h1 {
  margin: 0;
  color: white;
  font-size: 28px;
  font-weight: 600;
  flex: 1;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.content-container {
  max-width: 1400px;
  margin: 0 auto;
}

.plan-overview {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.overview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

.overview-header h2 {
  color: #2c3e50;
  font-size: 24px;
  margin: 0;
}

.plan-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plan-selector label {
  font-weight: 600;
  color: #2c3e50;
}

.child-select {
  padding: 8px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  color: #2c3e50;
  background: white;
  cursor: pointer;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.overview-stat {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
}

.stat-icon {
  font-size: 32px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 10px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 14px;
  color: #7f8c8d;
}

.plan-progress {
  margin-top: 25px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
  color: #2c3e50;
}

.progress-percent {
  color: #667eea;
}

.progress-bar-large {
  width: 100%;
  height: 12px;
  background: #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill-large {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.plan-content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.calendar-section,
.tasks-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.calendar-header h3 {
  color: #2c3e50;
  font-size: 20px;
  margin: 0;
}

.calendar-nav-btn {
  width: 35px;
  height: 35px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #2c3e50;
  font-size: 18px;
}

.calendar-nav-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-weekday {
  text-align: center;
  font-weight: 600;
  color: #7f8c8d;
  font-size: 14px;
  padding: 10px 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  background: white;
}

.calendar-day:hover {
  border-color: #667eea;
  background: #f8f9fa;
}

.calendar-day.other-month {
  opacity: 0.3;
  cursor: default;
}

.calendar-day.today {
  border-color: #667eea;
  background: #f0f4ff;
  font-weight: 600;
}

.calendar-day.has-task {
  border-color: #27ae60;
}

.calendar-day.completed {
  background: #d4edda;
}

.day-number {
  font-size: 14px;
  color: #2c3e50;
}

.day-indicator {
  position: absolute;
  bottom: 2px;
  font-size: 10px;
}

.completed-dot {
  color: #27ae60;
}

.task-dot {
  color: #f39c12;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.tasks-header h3 {
  color: #2c3e50;
  font-size: 20px;
  margin: 0;
}

.tasks-filter {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 6px 12px;
  background: #f8f9fa;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #7f8c8d;
}

.filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
}

.tasks-list {
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 2px solid #e0e0e0;
  transition: all 0.3s ease;
}

.task-item:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.task-item.completed {
  opacity: 0.7;
  background: #e8f5e9;
}

.task-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid #667eea;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.task-item.completed .task-checkbox {
  background: #27ae60;
  border-color: #27ae60;
}

.check-icon {
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.task-content {
  flex: 1;
}

.task-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: #7f8c8d;
}

.task-meta {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: #7f8c8d;
}

.task-actions {
  display: flex;
  gap: 5px;
}

.task-action-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
  border-radius: 6px;
}

.task-action-btn:hover {
  background: #e0e0e0;
}

.empty-tasks {
  text-align: center;
  padding: 40px;
  color: #7f8c8d;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.add-task-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.add-task-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.plan-settings {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.plan-settings h2 {
  color: #2c3e50;
  font-size: 24px;
  margin-bottom: 25px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 25px;
  margin-bottom: 25px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-item label {
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
}

.setting-value {
  font-size: 18px;
  font-weight: 700;
  color: #667eea;
}

.setting-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: pointer;
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: #667eea;
}

input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.time-input {
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  color: #2c3e50;
}

.time-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.save-settings-btn {
  padding: 12px 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.save-settings-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 弹窗样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: white;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
  margin: 0;
  color: #2c3e50;
  font-size: 20px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #7f8c8d;
}

.modal-close:hover {
  background: #e74c3c;
  color: white;
}

.modal-body {
  padding: 25px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  color: #2c3e50;
  transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-row span {
  color: #7f8c8d;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 25px;
  border-top: 1px solid #e0e0e0;
}

.btn-cancel,
.btn-confirm {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-cancel {
  background: #f5f5f5;
  color: #7f8c8d;
}

.btn-cancel:hover {
  background: #e0e0e0;
}

.btn-confirm {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

@media (max-width: 768px) {
  .plan-content-grid {
    grid-template-columns: 1fr;
  }

  .overview-stats {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}
</style>
